package util;

import constantClass.Constant;
import information.Information;

import java.lang.reflect.InvocationTargetException;

public class HandlerInvoke {
    public static Object invoke(Information information){
        return invokeFun(information);
    }
    private static Object invokeFun(Information information){
        Object invoke=null;
        //给参数赋值
        Object[] objects = MethodParameterChangeType.init(information.getMethod());
         try {
             HandFactory handFactory=(HandFactory)(HttpFactory.getActionFaction().getRequest().getServletContext().getAttribute(Constant.FACTORY));
             invoke = information.getMethod().invoke(handFactory.createAction(information) , objects);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return invoke;
    }
}
